package jpa;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EditHandler implements IRequestHandler {

	@Override
	public void handleRequest(HttpServletRequest request,
			HttpServletResponse response, IStatelessBean stateless,
			IStatefulBean stateful, ServletContext sc) throws ServletException, IOException 
	{	
		//Need to get ID passed in from link in admin
		int id      = Integer.parseInt(request.getParameter("id"));
		String name = request.getParameter("cacheName");
		String desc = request.getParameter("cacheDesc");
		Double lat  = Double.parseDouble(request.getParameter("cacheLat"));
		Double lon  = Double.parseDouble(request.getParameter("cacheLon"));
		
		stateless.editCache(id, name, desc, lat, lon);
		
		RequestDispatcher rd = request.getRequestDispatcher("viewCache.jsp");
        rd.forward(request, response);

	}

}
